<?php

namespace app\admin\validate;

use think\validate;
class Goods extends Validate
{


    protected $rule =   [

        'name'  => 'require|length:2,100',
//        'selection_criteria'=>'require',

        'cate_id'=>'require',
        'thumb'=>'require',
       // 'album'=>'require',
        'status'=>'require|between:1,2'
    ];

    protected $message  =   [
        'name.require'     => ['code' => 4021, 'msg' => '标题不能为空'],
        'name.unique'      => ['code' => 4022, 'msg' => '标题已经存在'],
        'name.length'      => ['code' => 4023, 'msg' => '长度是4到100位'],
//      'selection_criteria.require'      => ['code' => 4025, 'msg' => '选择标准必填'],
        'cate_id.require'      => ['code' => 4028, 'msg' => '分类必填'],
        //'album.require'      => ['code' => 4031, 'msg' => '作品图片必填'],
        'thumb.require'      => ['code' => 4032, 'msg' => '封面必须'],
        'status.require'      => ['code' => 4033, 'msg' => '状态必填'],
        'status.between'      => ['code' => 4034, 'msg' => '状态码不存在'],

    ];

    // 自定义验证规则
    protected function checkTitle($value,$rule,$data=[])
    {
        $rule = ['name'    =>  'unique:goods,title^uid='.$data['uid'],];
        return $this->check($data,$rule);
    }

}